package com.google.code.swingonfire.plotter;

import java.awt.BasicStroke;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.Stroke;
import java.awt.geom.Line2D;

public class SunSketch implements Sketch
{

    private static final Rectangle BOUNDS = new Rectangle(-8, -8, 16, 16);
    private static final Stroke STROKE = new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);

    private final int rays;

    public SunSketch(int rays)
    {
        super();

        this.rays = rays;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Rectangle getBounds()
    {
        return BOUNDS;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void draw(Graphics2D g)
    {
        g.fillOval(-4, -4, 8, 8);
        g.setStroke(STROKE);

        for (int i = 0; i < rays; i += 1)
        {
            g.draw(new Line2D.Double(0, -5, 0, -7.5));
            g.rotate((Math.PI * 2) / rays);
        }
    }

}
